/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.unibo.as.HeartsLogic;

import java.util.ArrayList;

/**
 *
 * @author lilith
 */
public class GameState 
{
    private final int DOWN;
    private final int LEFT;
    private final int UP;
    private final int RIGHT;
    
    ArrayList<String> MyCardArray = null;
    
    int numberPlayerCard[];
    String playedCard[];
    String playedID[];
    int tableState;

    public GameState(int nTableState, boolean bActivePlayer, int nDownPlayer, Player[] playerArray) 
    {
        DOWN  = nDownPlayer;
        LEFT  = (DOWN + 1)%Common.PLAYER_NUM;
        UP    = (LEFT + 1)%Common.PLAYER_NUM;
        RIGHT = (UP + 1)%Common.PLAYER_NUM;
        
        numberPlayerCard = new int[Common.PLAYER_NUM];
        playedCard = new String[Common.PLAYER_NUM];
        playedID = new String[Common.PLAYER_NUM];
        
        tableState = nTableState;
        
        for(int i = 0; i < Common.PLAYER_NUM; i++)
        {
            playedID[i] = playerArray[i].getPlayerID();
        }
        
        if(nTableState != Common.TURN_INIT)
        {
            if(bActivePlayer)
            {
                ArrayList<Card> cardArray = playerArray[nDownPlayer].getCards();
                for(int i = 0; i < cardArray.size(); i++)
                {
                    MyCardArray.add(cardArray.get(i).getCardString());
                }
            }

            for(int i = 0; i < Common.PLAYER_NUM; i++)
            {
                numberPlayerCard[i] = playerArray[i].CardArray.size();
                playedCard[i] = playerArray[i].playedCard.getCardString();
            }
        }
    }

    public ArrayList<String> getMyCardArray() 
    {
        return MyCardArray;
    }

    public int getDOWNPlayerCard() 
    {
        return numberPlayerCard[DOWN];
    }

    public String getDOWNPlayedCard() 
    {
        return playedCard[DOWN];
    }
    
    public String getDOWNPlayerID() 
    {
        return playedID[DOWN];
    }
    
    public int getLEFTPlayerCard() 
    {
        return numberPlayerCard[LEFT];
    }

    public String getLEFTPlayedCard() 
    {
        return playedCard[LEFT];
    }
    
    public String getLEFTPlayerID() 
    {
        return playedID[LEFT];
    }
    
    public int getUPPlayerCard() 
    {
        return numberPlayerCard[UP];
    }

    public String getUPPlayedCard() 
    {
        return playedCard[UP];
    }
    
    public String getUPPlayerID() 
    {
        return playedID[UP];
    }
    
    public int getRIGHTPlayerCard() 
    {
        return numberPlayerCard[RIGHT];
    }

    public String getRIGHTPlayedCard() 
    {
        return playedCard[RIGHT];
    }
    
    public String getRIGHTPlayerID() 
    {
        return playedID[RIGHT];
    }

    public int getTableState() {
        return tableState;
    }
    
}
